/**
 * @File name : UserServiceImpl.java
 * @Description : 
 * @Creator : haifeng17
 * @CreateTime : Mar 7, 2017 7:46:29 PM
 * @Version : 1.0
 * @Update records:
 *      1.1 Mar 7, 2017 by haifeng17: 
 *      1.0 Mar 7, 2017 by haifeng17: Created 
 * All rights served : XXX CORP.
 */
package com.ent.app.bms.service.system.impl;

import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ent.app.bms.bean.SysUser;
import com.ent.app.bms.bean.SysUserExample;
import com.ent.app.bms.dao.mapper.SysRoleMapper;
import com.ent.app.bms.dao.mapper.SysUserMapper;
import com.ent.app.bms.service.system.UserService;
import com.ent.app.bms.util.PageData;

@Service("userService")
public class UserServiceImpl implements UserService{

    @Resource
    private SysUserMapper userDao;
    @Resource
    private SysRoleMapper roleDao;
    @Override
    public SysUser findByUsername(String username) {
        SysUserExample example = new SysUserExample();
        SysUser sysUser = null;
        example.createCriteria().andUsernameEqualTo(username);
        List<SysUser> userList = userDao.selectByExample(example);
        if(userList!=null && userList.size() > 0){
            sysUser = userList.get(0);
        }
        return sysUser;
    }
    @Override
    public Set<String> findRoles(String username) {
        return null;
    }
    @Override
    public Set<String> findPermissions(String username) {
        return null;
    }
    @Override
    public SysUser findUserByNameAndPwd(String username, String password) throws Exception {
        SysUserExample example = new SysUserExample();
        SysUser sysUser = null;
        example.createCriteria().andUsernameEqualTo(username).andPasswordEqualTo(password);
        List<SysUser> userList = userDao.selectByExample(example);
        if(userList!=null && userList.size() > 0){
            sysUser = userList.get(0);
        }
        return sysUser;
    }
    @Override
    public PageData getUserByNameAndPwd(PageData pd) throws Exception {
        return null;
    }
    @Override
    public int saveUser(SysUser user) throws Exception {
        return userDao.insert(user);
    }
}
